package com.lvmama.rhino.base;

import javax.servlet.ServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.util.SavedRequest;

public class WebUtils {
    public static final String SAVED_REQUEST_KEY = "shiroSavedRequest";
    
    public static SavedRequest getSaveRequest(ServletRequest request){
        SavedRequest savedRequest = null;
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession(false);
        if(session != null){
            savedRequest = (SavedRequest) session.getAttribute(SAVED_REQUEST_KEY);
        }
        return savedRequest;
    }
}
